package com.tepth.remote.control.delegate.apply.examination;

import com.tepth.remote.control.base.config.ApiDictionary;
import com.tepth.remote.core.net.callback.IError;
import com.tepth.remote.core.net.callback.ISoapSuccess;

import org.jetbrains.annotations.NotNull;
import org.ksoap2.serialization.SoapObject;

import java.util.WeakHashMap;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/23
 */
public class ExaminationPresenter extends ExaminationContract.AbstractPresenter {
    private final ExaminationContract.View mView;
    private final ExaminationContract.Model mModel;

    public ExaminationPresenter(@NotNull ExaminationContract.View view) {
        mView = view;
        mModel = new ExaminationModel();
    }

    @Override
    void onExamination(int id, int targetId, final int type, String reason) {
        mView.showLoading("正在加载");
        final WeakHashMap<String, Object> params = new WeakHashMap<>();
        params.put("uid", id);
        params.put("xid", targetId);
        params.put("applyType", type);
        params.put("reason", reason);
        mModel.onExamination(params, ApiDictionary.API_HANDLE_EXCEPTION, ApiDictionary.SOAP_NAME_SPACE, new ISoapSuccess() {
            @Override
            public void onSuccess(SoapObject object) {
                mView.examinationSuccess(type);
            }
        }, new IError() {
            @Override
            public void onError(int code, String msg) {
                mView.examinationFailed(code, msg);
            }
        });
    }
}
